/**
 * Created by rockyren on 15/1/6.
 */
$(document).ready(function(){
  //url中的文件路径名
  var pathname = window.location.pathname;

  var $mainLi = $('.main-li');

  //先删除li的所有active类
  $mainLi.removeClass('active');
  $mainLi.each(function(){
    var $curAnchor = $(this).find('a');

    //找到对应的href
    var curHref = $curAnchor.attr('href');


    //如果pathname包含a的href的字符串，则添加active类
    if(pathname.indexOf(curHref) != -1){
      $(this).addClass('active');
    }

  });
});